import request from '@/utils/request'
import type { categoryResponseData } from './model/attr'

// 枚举API
enum API {
    // 一级分类地址
    C1='/admin/product/getCategory1',
    // 二级分类地址
    C2='/admin/product/getCategory2/',
    // 三级分类地址
    C3='/admin/product/getCategory3/',
    // 商品基本属性的地址
    ATTRLIST='/admin/product/attrInfoList/',
    ATTR='/admin/product/saveAttrInfo',
    DELETEATTR='/admin/product/deleteAttr/'
}


// 获取一级分类的接口
export const reqC1List = () =>request.get<any,categoryResponseData>(API.C1)


// 获取二级分类的接口
export const reqC2List = (category1Id:number | string) =>request.get<any,categoryResponseData>(API.C2 + category1Id)


// 获取三级分类的接口
export const reqC3List = (category2Id:number | string) =>request.get<any,categoryResponseData>(API.C3 + category2Id)

// 获取商品基本属性的接口
export const reqAttrList = (category1Id:number|string,category2Id:number|string,category3Id:number|string)=>request.get(API.ATTRLIST + `${category1Id}/${category2Id}/${category3Id}`)

// 添加/修改属性的接口
export const reqAddOrUpdateAttr = (data:any)=>request.post(API.ATTR,data)

// 删除属性的接口
export const reqDeleteAttr = (id:number)=>request.delete(API.DELETEATTR + id)